import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.*;

// ================= 用户类 =================
class User {
    private String userId;
    private String username;
    private String passwordHash; // MD5密码
    private String role; // admin / manager / cashier
    private String phone;
    private String registerTime;

    public User(String userId, String username, String passwordHash, String role, String phone, String registerTime) {
        this.userId = userId;
        this.username = username;
        this.passwordHash = passwordHash;
        this.role = role;
        this.phone = phone;
        this.registerTime = registerTime;
    }

    public String getUserId() { return userId; }
    public String getUsername() { return username; }
    public String getPasswordHash() { return passwordHash; }
    public String getRole() { return role; }
    public String getPhone() { return phone; }
    public String getRegisterTime() { return registerTime; }

    public void setPasswordHash(String passwordHash) { this.passwordHash = passwordHash; }
    public void setRole(String role) { this.role = role; }
    public void setPhone(String phone) { this.phone = phone; }

    @Override
    public String toString() {
        return userId + "," + username + "," + passwordHash + "," + role + "," + phone + "," + registerTime;
    }

    public static User fromString(String line) {
        String[] parts = line.split(",");
        if (parts.length != 6) return null;
        return new User(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5]);
    }
}
